﻿@using EasyAbp.ProcessManagement.Localization
@using EasyAbp.ProcessManagement.Web.Options
@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.Extensions.Localization
@using Microsoft.Extensions.Options
@inject IHtmlLocalizer<ProcessManagementResource> L
@inject IOptions<ProcessManagementWebOptions> Options
@inject IStringLocalizerFactory StringLocalizerFactory
@model EasyAbp.ProcessManagement.Web.Components.NotificationsOffcanvasWidget.NotificationsOffcanvasWidgetViewModel

@{
    var customActions = "[" + Options.Value.Actions.Select(x =>
            $"{{text:'{x.DisplayName.Localize(StringLocalizerFactory)}',action:function(data){{{x.OffcanvasOnClickCallbackCode}}},visible:function(data){{return data.processName==='{x.ProcessName}'&&data.stateName==='{x.StateName}'&&({x.VisibleCheckCode ?? "true"})}}}}")
        .JoinAsString(",") + "]";
}
<script>
    const notificationLifetimeMilliseconds = @Model.Options.NotificationLifetime.TotalMilliseconds;
    var notificationOffcanvasAlertActions = @Html.Raw(customActions);
</script>

<style>
    .notification-offcanvas-action-area {
        height: 40px;
        .more-processes-btn {
            float: left;
            padding: 0;
            text-decoration: none;
            color: var(--bs-offcanvas-color);
        }
        .dismiss-all-noti-btn {
            float: right;
            padding: 0;
            text-decoration: none;
            color: var(--bs-offcanvas-color);
        }
    }
    .alert-content-title {
        gap: 10px;
        h6 {
            margin: 0;
        }
        .svg-icon {
            width: 24px;
            height: 24px;
        }
    }
    .alert-content-area {
        padding-left: 34px;
        .process-action-btn {
            padding-top: 0;
            padding-bottom: 0;
            padding-left: 0;
            color: var(--bs-offcanvas-color);
        }
    }
    .no-notification-text {
        text-align: center;
        margin-top: 10px;
    }
    .state-update-time {
        position: absolute;
        bottom: 0;
        right: 0;
        padding: .8rem 1rem;
        text-align: right !important;
    }
    .alert-purple {
        background-color: #cf9ce6;
        color: #212529;
    }
    .fade-in {
        animation: fadeIn 0.5s;
    }
    .fade-out {
        animation: fadeOut 0.5s;
    }
    @@keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    @@keyframes fadeOut {
        from { opacity: 1; }
        to { opacity: 0; }
    }
</style>

<div class="offcanvas offcanvas-end" tabindex="-1" id="notificationsOffcanvas"
     aria-labelledby="notificationsOffcanvasLabel">
    <div class="offcanvas-header">
        <h4 class="offcanvas-title" id="notificationsOffcanvasLabel">@L["Notifications"]</h4>
        <button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
    </div>
    <div class="offcanvas-body" style="padding-top: 0">
        <div class="notification-offcanvas-action-area">
            <button type="button" id="notification-offcanvas-more-processes-btn" class="more-processes-btn btn btn-link">
                <small>@L["MoreProcesses"]</small>
            </button>
            <button type="button" id="notification-offcanvas-dismiss-all-btn" class="dismiss-all-noti-btn btn btn-link">
                <small>@L["DismissAllNotifications"]</small>
            </button>
        </div>
        <div id="no-notification-text" class="no-notification-text">
            <small>@L["NoNotification"]</small>
        </div>
        <div id="alert-placeholder"></div>
    </div>
</div>